<?php
class Mozg_Source_Table_Data
{
	private $_data = array();
	private $_delimiter = ':';
	
	public function Set($path, $value)
	{
		if (false === strpos($path, $this->_delimiter))
		{
			$this->_data[$path] = $value;
			return $this;
		}

		$nameParts = explode($this->_delimiter, $path);
		
		$data = &$this->_data;
		while (list(,$name) = each($nameParts))
		{
			if (!isset($data[$name])) $data[$name] = array();
			$data = &$data[$name];
		}

		$data = $value;
		return $this;
	}
	
	public function __set($name, $value)
	{
		return $this->Set($name, $value);
	}

	public function ImportData(array $data = array())
	{
		foreach ($data as $name => $value)
		{
			$this->Set($name, $value);
		}
	}
	
	public function ExportData()
	{
		return $this->_data;
	}
}